package com.appkubes.mall.admin.application.activity.apply.apply.controller;

import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.admin.application.activity.apply.apply.entity.dto.InspectionManageSupplierDTO;
import com.appkubes.mall.admin.application.activity.apply.apply.entity.vo.ApplyInspectionVO;
import com.appkubes.mall.admin.application.activity.apply.apply.entity.vo.InspectionManageSupplierVO;
import com.appkubes.mall.admin.application.activity.apply.apply.service.ActivityApplyService;
import com.appkubes.mall.core.controller.BaseMallActivityApplyController;
import com.appkubes.mall.core.entity.MallActivityApply;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @Author: Rongjie
 * @Date: 2020/3/4
 * @Description:
 */
@Api(tags = "活动申请模块")
@RestController
public class ActivityApplyController extends BaseMallActivityApplyController {

    @Autowired
    ActivityApplyService activityApplyService;

    @ApiOperation(value = "申请验货（达人申请验货）")
    @PostMapping(value = "/applyInspection")
    public Response applyInspection(@ParamValid ApplyInspectionVO applyInspectionVO){
        MallActivityApply apply = new MallActivityApply();
        BeanUtils.copyProperties(applyInspectionVO,apply);

        apply.setApplyNo("123456");
        apply.setCreateTime(new Date());
        apply.setStatus("PENDING");
        this.baseService.save(apply);
        return Response.success();
    }

    @ApiOperation(value = "验货管理（商家验货管理）")
    @PostMapping(value = "/inspectionManageSupplier")
    public Response inspectionManageSupplier(@ParamValid InspectionManageSupplierVO inspectionManageSupplierVO){
        Page page = new Page(inspectionManageSupplierVO.getPage(),inspectionManageSupplierVO.getSize());
        List<InspectionManageSupplierDTO> list = activityApplyService.inspectionManageSupplier(page,inspectionManageSupplierVO.getSupplierKey());
        return Response.success(list);
    }

}
